<?php
include("_mysql.php");
include("_settings.php");
include("_functions.php");
?>

<div class="contentMenuTab">
	<h1><a href="?p=cp_profile"><?=username($userID)?></a> <span>Bets</span></h1>
	<div class="clearafter bets">
		<div>Click on the bets for more information. Bets marked with green is yours.</div>
		<div class="activeBets">
			<h3>Active</h3>
			<table cellspacing="0" cellpadding="0" width="100%">
				<thead>
					<tr>
						<th class="first">Bet</th>
						<th class="highlight">Your bet</th>
						<th>Bets</th>
						<th class="highlight">Pot</th>
						<th>Est. win</th>
					</tr>
				</thead>
				<tbody> <!-- highlight-green -->
				
				<?php
				$bets = safe_query("SELECT * FROM bets WHERE user='".$userID."' ORDER BY date DESC LIMIT 0,10");
				$i = 1;
				while($ds=mysql_fetch_array($bets))
				{
				$item = mysql_fetch_array(safe_query("SELECT * FROM item WHERE id='".$ds['itemID']."'"));
				$title = cut($item['title'], 50);
				
				$my_bet = $ds['money'];
				$all_bets = safe_query("SELECT money FROM bets WHERE itemID='".$ds['itemID']."'");
				$bets_count = mysql_num_rows($all_bets);
				$bet_pot = 0;
				while($bet = mysql_fetch_array($all_bets))
				$bet_pot = $bet_pot + $bet['money'];
				
				if ($i % 2 == 0) $odd = 'class="odd"';
				$i++;
				echo
				'
				<tr '.$odd.'>
						<td class="first">'.$title.'</td>
						<td class="highlight">$'.$my_bet.'</td>
						<td>'.$bets_count.'</td>
						<td class="highlight">$'.$bet_pot.'</td>
						<td>$20</td>
				</tr>';
				
				$odd = '';
				
				}
				?>
				</tbody>
			</table>
		</div>
		<div class="historyBets">
			<h3>History</h3>
			<table cellspacing="0" cellpadding="0" width="100%">
				<thead>
					<tr>
						<th class="first">Bet</th>
						<th class="highlight">Your bet</th>
						<th>Bets</th>
						<th class="highlight">Pot</th>
						<th>Results</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr class="odd">
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr class="highlight-green">
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr class="odd">
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr>
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="red">$20</td>
					</tr>
					<tr class="odd highlight-green">
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr>
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr class="odd">
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="red">$20</td>
					</tr>
					<tr>
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
					<tr class="odd">
						<td class="first">I bet ipsum dolor sit amet dolor dolan </td>
						<td class="highlight">$10</td>
						<td>23</td>
						<td class="highlight">$160</td>
						<td class="green">$20</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>